using System;
using Microsoft.SPOT;

namespace Robot
{
    /// <summary>
    /// Contains static Microsleep function
    /// </summary>
    class MicroSleep
    {
        /// <summary>
        /// Sleeps for specified amount of microseconds
        /// </summary>
        /// <param name="microseconds">Specifies how many microseconds to sleep</param>
        public static void Microsleep(int microseconds)
        {
            // Calculate Stop time
            long stop = DateTime.Now.Ticks + microseconds * 10;

            // Do the real sleeping. Choose between naughty and nice...
            while (DateTime.Now.Ticks < stop)
//                ;
                System.Threading.Thread.Sleep(0);
        }
    }
}
